From: Daniel Friesen Date: Sat, 24 Mar 2012 08:25:01 +0000 (-0700) Subject: Separate $wgArticlePath from $wgUsePathInfo. X-Git-Tag: 1.31.0-rc.0~24036^2 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=9d837976314a88918ad20d92c66da704043190e0;p=lhc%2Fweb%2Fwiklou.git Separate $wgArticlePath from $wgUsePathInfo. - $wgUsePathInfo is now only used on servers not passing REQUEST_URI to determine if PATH_INFO should be used - WebRequest now extracts information from REQUEST_URI even when $wgUsePathInfo is false - HTMLForm bases it's decision on whether or not to include a hidden 'title' input on whether $wgArticlePath uses a query instead of assuming that $wgUsePathInfo was used to set the article path Change-Id: I1b461fef88b26d045f4edd7553b59255c5e595d8 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index d4533aac3b..72b9683f8d 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -11,6 +11,9 @@ MediaWiki 1.20 is an alpha-quality branch and is not recommended for use in production. === Configuration changes in 1.20 === +* `$wgUsePathInfo = true;` is no longer needed to make $wgArticlePath work on servers + using like nginx, lighttpd, and apache over fastcgi. MediaWiki now always extracts + path info from REQUEST_URI if it's available. === New features in 1.20 === * Added TitleIsAlwaysKnown hook which gets called when determining if a page exists. diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index dccf96766a..74174b5bb4 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -516,7 +516,7 @@ class HTMLForm extends ContextSource { * @return String HTML. */ function getHiddenFields() { - global $wgUsePathInfo; + global $wgArticlePath; $html = ''; if( $this->getMethod() == 'post' ){ @@ -524,7 +524,7 @@ class HTMLForm extends ContextSource { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } - if ( !$wgUsePathInfo && $this->getMethod() == 'get' ) { + if ( strpos( $wgArticlePath, '?' ) !== false && $this->getMethod() == 'get' ) { $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; } diff --git a/includes/WebRequest.php b/includes/WebRequest.php index 9b66d7d86d..81f42dcc79 100644 --- a/includes/WebRequest.php +++ b/includes/WebRequest.php @@ -77,6 +77,7 @@ class WebRequest { * @return Array: Any query arguments found in path matches. */ static public function getPathInfo( $want = 'all' ) { + global $wgUsePathInfo; // PATH_INFO is mangled due to http://bugs.php.net/bug.php?id=31892 // And also by Apache 2.x, double slashes are converted to single slashes. // So we will use REQUEST_URI if possible. @@ -134,15 +135,17 @@ class WebRequest { $matches = $router->parse( $path ); } - } elseif ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { - // Mangled PATH_INFO - // http://bugs.php.net/bug.php?id=31892 - // Also reported when ini_get('cgi.fix_pathinfo')==false - $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); - - } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') ) { - // Regular old PATH_INFO yay - $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + } elseif ( $wgUsePathInfo ) { + if ( isset( $_SERVER['ORIG_PATH_INFO'] ) && $_SERVER['ORIG_PATH_INFO'] != '' ) { + // Mangled PATH_INFO + // http://bugs.php.net/bug.php?id=31892 + // Also reported when ini_get('cgi.fix_pathinfo')==false + $matches['title'] = substr( $_SERVER['ORIG_PATH_INFO'], 1 ); + + } elseif ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != '') ) { + // Regular old PATH_INFO yay + $matches['title'] = substr( $_SERVER['PATH_INFO'], 1 ); + } } return $matches; @@ -206,18 +209,14 @@ class WebRequest { * available variant URLs. */ public function interpolateTitle() { - global $wgUsePathInfo; - // bug 16019: title interpolation on API queries is useless and sometimes harmful if ( defined( 'MW_API' ) ) { return; } - if ( $wgUsePathInfo ) { - $matches = self::getPathInfo( 'title' ); - foreach( $matches as $key => $val) { - $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val; - } + $matches = self::getPathInfo( 'title' ); + foreach( $matches as $key => $val) { + $this->data[$key] = $_GET[$key] = $_REQUEST[$key] = $val; } }